home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Champak 40
/
Vol 40.iso
/
games
/
360_derg.swf
/
scripts
/
frame_1
/
DoAction.as
Wrap
Text File
|
2007-05-10
|
5KB
|
179 lines
function move()
{
var _loc1_ = _root;
posx[0] = _loc1_.snake._x;
posy[0] = _loc1_.snake._y;
_loc1_.snake._x += 4 * Math.cos(0.017453292519943295 * theta);
_loc1_.snake._y += 4 * Math.sin(0.017453292519943295 * theta);
if(_loc1_.init)
{
t = 0;
while(t < _loc1_.snakelength)
{
nn = "body" + Number(t);
duplicateMovieClip("snake",nn,16384 + t);
nn._x = -20;
nn._y = -20;
t++;
}
_loc1_.init = false;
_loc1_.specialtime.stime = 0;
_loc1_.specialtime.sout = false;
_loc1_.specialtime._visible = false;
}
_loc1_.ltf();
t = _loc1_.snakelength - 1;
while(t > 0)
{
posx[t] = posx[t - 1];
posy[t] = posy[t - 1];
t--;
}
if(collide(_loc1_.food._x,_loc1_.food._y))
{
_loc1_.foods = false;
t = 0;
while(t < 20)
{
nn = "body" + Number(_loc1_.snakelength);
duplicateMovieClip("snake",nn,16384 + _loc1_.snakelength);
nn._x = -20;
nn._y = -20;
posx[_loc1_.snakelength] = posx[_loc1_.snakelength - 1];
posy[_loc1_.snakelength] = posy[_loc1_.snakelength - 1];
_loc1_.snakelength = _loc1_.snakelength + 1;
t++;
}
t = 0;
while(t < _loc1_.snakelength)
{
nn = "body" + Number(t);
setProperty(nn, _X, posx[t]);
setProperty(nn, _Y, posy[t]);
t++;
}
_loc1_.count = 0;
_loc1_.score += 5;
}
if(collide(_loc1_.specialfood._x,_loc1_.specialfood._y))
{
_loc1_.score += Number(_loc1_.specialtime.spoints);
_loc1_.specialtime.spoints = 0;
_loc1_.specialtime.stime = 0;
_loc1_.specialfood._x = -30;
_loc1_.specialfood._y = -20;
_loc1_.specialtime.sout = false;
_loc1_.specialtime._visible = false;
}
if(_loc1_.specialtime.sout)
{
_loc1_.specialtime.stime -= 1;
_loc1_.specialtime.spoints = int(_loc1_.specialtime.stime / 10.5);
if(_loc1_.specialtime.stime == 0)
{
_loc1_.specialfood._x = -30;
_loc1_.specialfood._y = -20;
_loc1_.specialtime.sout = false;
_loc1_.specialtime._visible = false;
}
}
if(!_loc1_.foods)
{
x = random(292) + 19;
y = random(272) + 19;
_loc1_.food._x = x;
_loc1_.food._y = y;
if(_loc1_.score != 0 && (_loc1_.snakelength - 19) % 100 == 0)
{
sx = random(292) + 19;
sy = random(272) + 19;
_loc1_.specialfood._x = sx;
_loc1_.specialfood._y = sy;
_loc1_.specialtime.stime = 210;
_loc1_.specialtime.spoints = 20;
_loc1_.specialtime.sout = true;
_loc1_.specialtime._visible = true;
}
_loc1_.foods = true;
}
if(_loc1_.snake._x < 10 || _loc1_.snake._x > 310 || _loc1_.snake._y < 10 || _loc1_.snake._y > 290)
{
_loc1_.destroy();
}
t = 0;
while(t < _loc1_.snakelength)
{
if(collide(posx[t],posy[t]))
{
_loc1_.destroy();
}
t++;
}
}
function ltf()
{
var _loc1_ = _root;
last = _loc1_.snakelength - 1 - _loc1_.count;
nn = "body" + Number(last);
_loc1_.count = _loc1_.count + 1;
if(last == 0)
{
_loc1_.count = 0;
}
setProperty(nn, _X, posx[0]);
setProperty(nn, _Y, posy[0]);
}
function collide(objectx, objecty)
{
delta_x = _root.snake._x - objectx;
delta_y = _root.snake._y - objecty;
if(delta_x * delta_x + delta_y * delta_y < 15)
{
return true;
}
return false;
}
function destroy()
{
var _loc1_ = _root;
_loc1_.crash._x = _loc1_.snake._x;
_loc1_.crash._y = _loc1_.snake._y;
t = 0;
while(t < _loc1_.snakelength)
{
nn = "body" + Number(t);
removeMovieClip(nn);
t++;
}
_loc1_.snake._visible = false;
_loc1_.crash.gotoAndPlay(2);
if(score > _loc1_.scoretable.topten.SCORE9)
{
gotoAndStop(5);
}
else
{
gotoAndStop(4);
}
}
sfile = "http://www.s4websolutions.com/rsnake/scores.php";
sview = sfile + "?filename=score.sco&scoresize=10&action=VIEW&viewtype=FLASH";
posx = new Array();
posy = new Array();
snakelength = 19;
t = 0;
while(t < snakelength)
{
posx[t] = -20;
posy[t] = -20;
t++;
}
init = true;
theta = 0;
foods = false;
score = 0;
count = 0;
_root.scoretable.topten.loadVariables(_root.sview);
_root.scoretable._visible = false;
stop();